package com.googlecode.archimedes.common;

import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.googlecode.archimedes.filegen.model.Entity;

/**
 * Document me! 
 * 
 * @author Erik Gustavson
 * @version $Id: XMLUtil.java 51 2003-11-28 18:23:31 +0000 (Fri, 28 Nov 2003) erik $
 *
 * Created on Oct 8, 2003
 */
public class XMLUtil {
	private Log logger = LogFactory.getLog(this.getClass().getName());
	/**
	 * Document me!
	 * 
	 * 
	 */
	public XMLUtil() {
		super();
	}

	public void simpleXMLEncode(Entity bo) {
		try {
			XMLEncoder e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("c:\\zzzz.xml")));
			e.writeObject(bo);
			e.close();
			logger.debug("Made it");
		} catch (Exception ex) {
			logger.debug("SHIT!");
		}

	}
	public void simpleXMLDecode() {
		try {
			XMLDecoder d = new XMLDecoder(new BufferedInputStream(new FileInputStream("Test.xml")));
			Object result = d.readObject();
			Entity bo = (Entity) result;
			logger.debug(bo.getDisplayName());
			logger.debug("Made it");
			d.close();
		} catch (Exception ex) {
			logger.debug("SHIT!");
		}
	}
}
